package com.fc.hkx.process.migrate;


import java.io.File;
import java.io.FileFilter;
import java.util.regex.Matcher;

/**
 * filters out all the files which are not file filters.
 * 
 * @author Chris
 */
public class VersionedFileFilter implements FileFilter {
    
    private int _version;
    
    /**
     * create's this filter, returning everything GREATER than the
     * current version.
     * 
     * @param currentVersion currentVersion
     */
    public VersionedFileFilter( int currentVersion ) {
        _version = currentVersion;
    }

    /**
     * returns true if it's a file filter
     */
    @Override
    public boolean accept(File file) {
        Matcher matcher = VersionedStringComparator.STRING_PATTERN.matcher(file.getName());
        return (matcher.matches() && Integer.parseInt(matcher.group(1)) > _version);
    }

}
